//
//  YQUser.m
//  WeiboOC
//
//  Created by yang on 15/11/20.
//  Copyright © 2015年 yang. All rights reserved.
//

#import "YQUser.h"

@implementation YQUser
+ (instancetype)userWithDict:(NSDictionary*)dict
{
    YQUser* user = [[self alloc] init];
    [user setValuesForKeysWithDictionary:dict];
    return user;
}
- (void)setValue:(id)value forKey:(NSString*)key
{
    if ([key isEqual:@"id"]) {
        self.ID = value;
        return;
    }
    [super setValue:value forKey:key];
}
- (void)setValue:(id)value forUndefinedKey:(NSString*)key
{
}
- (NSURL*)headImageURL
{
    if (self.profile_image_url) {
        return [NSURL URLWithString:self.profile_image_url];
    }
    return nil;
}
- (UIImage*)mbrankImage
{
    if (self.mbrank.intValue > 0 && self.mbrank.intValue < 7) {
        return [UIImage imageNamed:[NSString stringWithFormat:@"common_icon_membership_level%d", self.mbrank.intValue]];
    }
    return nil;
}
- (UIImage*)verified_typeImage
{
    switch (self.verified_type.intValue) {
    case 0:
        return [UIImage imageNamed:@"avatar_vip"];
        break;
    case 2:
        return [UIImage imageNamed:@"avatar_enterprise_vip"];
    case 3:
        return [UIImage imageNamed:@"avatar_enterprise_vip"];
    case 5:
        return [UIImage imageNamed:@"avatar_enterprise_vip"];
    case 220:
        return [UIImage imageNamed:@"avatar_grassroot"];
        break;
    default:
        return nil;
        break;
    }
}
@end
